import datetime
import time

from django import template
from django.http import HttpResponse
from django.shortcuts import render
from django.template import Context, Template, Library

from Apps.DataGeneration.DataGenerationClass.characterDataGeneration import CharacterDataGeneration
from Apps.DataGeneration.DataGenerationClass.textDataGeneration import TextDataGeneration
# Create your views here.

from Apps.Demo.models import Demo, Person, Dog
from Apps.Demo.ser import DemoSerializer, PersonSerializer, DogSerializer
from Apps.common.chart_request.corpChart import sendText
from Apps.common.response import SuccessResponse
from rest_framework.viewsets import ModelViewSet


class DemoView(ModelViewSet):
    serializer_class = DemoSerializer
    queryset = Demo.objects.all()
    authentication_classes = []


class PersonViewSet(ModelViewSet):
    serializer_class = PersonSerializer
    queryset = Person.objects.all()
    authentication_classes = []


class DogViewSet(ModelViewSet):
    serializer_class = DogSerializer
    queryset = Dog.objects.all()
    authentication_classes = []
    permission_classes = []


def dem():
    return TextDataGeneration().text({"max_nb_chars": 300})


def test_tem(request):
    template = Template("生成名字第一个： {{ random_text  }} <br><br>第二个： {{ random_text  }}!")
    context = Context({'random_text': dem})
    result = template.render(context)
    return HttpResponse(result)
